/*
 * @Description: 
 * @Author: 马爽
 * @Date: 2021-03-08 23:52:02
 * @LastEditTime: 2021-03-10 11:13:01
 * @LastEditors: 马爽
 */
import { FC } from 'react'
import { useDispatch } from 'umi';
import { Button, Input, Form} from 'antd';

const layout = {
  labelCol: { span: 8 },
  wrapperCol: { span: 16 },
};

const tailLayout = {
  wrapperCol: { offset: 1, span: 16 },
};

const Addapi:FC = () => {
    const dispatch = useDispatch();
    
    const [form] = Form.useForm();

    const onReset = () => {
        form.resetFields();
    };
        
    const onFinish = (values: any) => {
        // console.log('Success:', values);
        //是否成功 
        dispatch({
            type:'userManage/addAuthorityApi',
            payload:{...values}
        })
    };
    
    return (
        <div className='addbox'>
          <div className='btn'>
            <Button>添加api接口权限</Button>
          </div>
          <Form
            form={form}
            {...layout}
            name="basic"
            onFinish={onFinish}
            initialValues={{ remember: true }}
          >

            <Form.Item
              name="api_authority_text"
              rules={[{ required: true, message: 'api接口权限名称' }]}
            >
              <Input placeholder='请输入api接口权限名称' />
            </Form.Item>

            <Form.Item
              name="api_authority_url"
              rules={[{ required: true, message: 'api接口权限url' }]}
            >
              <Input placeholder='请输入api接口权限url' />
            </Form.Item>
            
            <Form.Item
              name="api_authority_method"
              rules={[{ required: true, message: 'api接口权限方法' }]}
            >
              <Input placeholder='请输入api接口权限方法' />
            </Form.Item>

            <Form.Item {...tailLayout}>
              <Button type="primary" htmlType="submit">
                确定
              </Button>
              <Button htmlType="button" onClick={onReset}>
                重置
              </Button>
            </Form.Item>
          </Form>
        </div>
    )
}

export default Addapi;